package com.team.dutchboy.service.impl;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.team.dutchboy.config.sentinel.FallbackHandler;
import com.team.dutchboy.service.DutchboyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class DutchboyServiceImpl implements DutchboyService {
    //注意不要用于controller 否则会无法捕获异常
//    @SentinelResource(value = "intf"
//        ,blockHandler="block"  仅捕获BlockException
//    ，fallback = "block" 为所有异常捕获 可以增加Throwable  与blockHandler只能选择一个 注意：返回值 入参与添加注解方法保持一致
//    )
//    @Override
//    public String test(int a) {
//
//        return "s12321da";
//    }
//
//    public String block(int a, BlockException e){
//        log.error("触发{}",e);
//        return "e";
//    }

    @SentinelResource(value = "intf"
            ,fallback="fallback"
            ,fallbackClass = FallbackHandler.class
    )
    @Override
    public String test(int a) {
        return "s123s21da";
    }

}
